import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'

export const MaterialFactory = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === '71228a74-dff3-4612-bf2a-4ffd0a5f5408') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增供应商" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '材料供应商名称' },
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '42017949-cbe7-4080-9430-19d821bc58e4') !== -1 && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '650b87c0-21df-4fb0-a18a-678fd900871c') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
